#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long n,l,r;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	if((r-l)%n<n&&(r-l)%n!=0)cout<<r%n;
	else cout<<n-1;
	return 0;
}
